from sqlalchemy import Column, Integer,String,Boolean, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlalchemy.pool import StaticPool

Base = declarative_base()
engine = create_engine("sqlite:///data.db",connect_args={'check_same_thread':False},
                    poolclass=StaticPool)
DBSession = sessionmaker(bind=engine)

class User(Base):
    __tablename__='user'

    id = Column(Integer,primary_key=True)
    tel = Column(Integer)
    passwd = Column(String(20))
    level = Column(Integer)

class Machine(Base):
    __tablename__='machine'
    id = Column(Integer,primary_key=True)
    mid = Column(Integer)
    bind = Column(Integer)
    level = Column(Integer)
    now = Column(String(20))

class Inventory(Base):
    __tablename__='inventory'
    id = Column(Integer,primary_key=True)
    medicine = Column(Integer)
    line=Column(Integer)
    number=Column(Integer)
    enable=Column(Boolean)

class Drug(Base):
    __tablename__='medicine'
    id = Column(Integer,primary_key=True)
    drug_id = Column(Integer)
    drug_name = Column(String(20))
    drug_level = Column(Integer)
    drug_sell=Column(Integer)
    drug_enable = Column(Boolean)

class Cookie(Base):
    __tablename__='cookie'
    id = Column(Integer,primary_key=True)
    cookie = Column(String(20))
    ip=Column(String(20))
    tel = Column(Integer)
    time = Column(Integer)
